package com.hhs.storage.controller;


import com.hhs.storage.bean.BaseUser;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.service.BaseLogsService;
import com.hhs.storage.service.BaseUserService;
import com.hhs.storage.util.SysUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 *  车队长管理
 * </p>
 *
 * @author shadow
 * @since 2018-09-29
 */
@RestController
@RequestMapping("carCaptain")
@Slf4j
public class CarCaptainController {
    @Resource
    BaseUserService userService;

    @RequestMapping(value = "table")
    public Map<String, Object> queryCarCaptain(InputParam inputParam) {
        return userService.queryCarCaptain(inputParam);
    }
    @PostMapping(value = "edit")
    public Map<String, Object> saveOrUpdate(@Validated BaseUser user){
        return userService.addOrUpdate(user,SysUtil.ROLE_FLAG_CDZ);
    }
    @RequestMapping(value = "dele")
    public Map<String, Object> dele(@RequestParam  String id) {
        try{
            return userService.dele(id);
        }catch (Exception e){
            e.printStackTrace();
            return ResponseInfo.error("业务关联，无法删除");
        }
    }
}

